package com.cdream.basic.algorithm.leetcode.string;

/**
 * @author cdream
 * @date 9/7/21
 */
public class Question1221 {
    public int balancedStringSplit(String s) {
        int count = s.charAt(0)=='R'? -1:1;
        int res = 0;
        for(int i =1; i<s.length()-1;i++){
            if(s.charAt(i)=='R'){
                count--;
            }else{
                count++;
            }
            if(count==0){
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        new Question1221().balancedStringSplit("RL");
    }
}
